﻿using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace MauiApp2.ViewModels;

public partial class MainPageViewModel : ObservableObject
{
    public MainPageViewModel()
    {
        Items = new ObservableCollection<string>();

    }

    [ObservableProperty]
    private ObservableCollection<string> items;

    [ObservableProperty]
    [NotifyPropertyChangedFor(nameof(ItemAdded))]
    private string itemName;

    public string ItemAdded => $"The Item u r adding is {ItemName}";

    [RelayCommand]
    void Tap()
    {
        if (string.IsNullOrWhiteSpace(ItemName))
        {
            return;
        }

        Items.Add(ItemName);

        ItemName = string.Empty;
    }


    [RelayCommand]
    void Del(string e)
    {
        Items.Remove(e);
    }


}